import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import { useUser } from '@/stores/loginer'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/LoginView',
      name: 'LoginView',
      component: () => import('../views/Login/LoginView.vue')
    },
    {
      path: '/userListView',
      name: 'userListView',
      component: () => import('../views/User/UserListView.vue')
    },
    {
      path: '/userUpdateInfo',
      name: 'userUpdateInfo',
      component: () => import('../views/User/UserUpdateInfo.vue')
    },
    {
      path: '/userInsertInfo',
      name: 'userInsertInfo',
      component: () => import('../views/User/UserInsertInfo.vue')
    },
    {
      path: '/roleListView',
      name: 'roleListView',
      component: () => import('../views/Role/RoleListView.vue')
    },
    {
      path: '/roleInsertInfo',
      name: 'roleInsertInfo',
      component: () => import('../views/Role/RoleInsertInfo.vue')
    },
    {
      path: '/roleUpdateInfo',
      name: 'roleUpdateInfo',
      component: () => import('../views/Role/RoleUpdateInfo.vue')
    },
    {
      path: '/menuInsertInfo',
      name: 'menuInsertInfo',
      component: () => import('../views/Menu/MenuInsertInfo.vue')
    },
    {
      path: '/menuListView',
      name: ',menuListView',
      component: () => import('../views/Menu/MenuListView.vue')
    },
    {
      path: '/menuUpdateInfo',
      name: 'menuUpdateInfo',
      component: () => import('../views/Menu/MenuUpdateInfo.vue')
    },
    {
      path: '/rolePressionView',
      name: 'rolePressionView',
      component: () => import('../views/Menu/RolePressionView.vue')
    },
    {
      path: '/sourceView',
      name: 'sourceView',
      component: () => import('../views/SourcePro/SourceView.vue')
    },
    {
      path: '/sourceDetailView',
      name: 'sourceDetailView',
      component: () => import('../views/SourcePro/SourceDetailView.vue')
    },
    {
      path: '/CultureListView',
      name: 'CultureListView',
      component: () => import('../views/Culture/CultureListView.vue')
    },
    {
      path: '/SlaughterListView',
      name: 'SlaughterListView',
      component: () => import('../views/Slaughter/SlaughterListView.vue')
    },
    {
      path: '/DeepProcessingListView',
      name: 'DeepProcessingListView',
      component: () => import('../views/DeepProcessing/DeepProcessingListView.vue')
    },
    {
      path: '/MobileTerminalList',
      name: 'MobileTerminalList',
      component: () => import('../views/MobileTerminal/MobileTerminalList.vue')
    },
    {
      path: '/CultureMobileTerminal',
      name: 'CultureMobileTerminal',
      component: () => import('../views/MobileTerminal/CultureMobileTerminal.vue')
    },
    {
      path: '/SlaughterMobileTerminal',
      name: 'SlaughterMobileTerminal',
      component: () => import('../views/MobileTerminal/SlaughterMobileTerminal.vue')
    },
    {
      path: '/DeppProcessingMobileTerminal',
      name: 'DeppProcessingMobileTerminal',
      component: () => import('../views/MobileTerminal/DeppProcessingMobileTerminal.vue')
    },
  ]
})

// router.beforeEach((to, from, next) => {
//   const useCount = useUser();
//   if (to.name !== 'LoginView' && !useCount.islogin) next({ name: 'LoginView' })
//   else next()
// })

export default router
